package com.lookme.lmtool.cracker.filter.effect;

import com.jhlabs.image.ChromeFilter;
import com.jhlabs.image.EmbossFilter;
import com.jhlabs.image.ImageMath;
import com.lookme.lmtool.cracker.CrackerConstants;
import com.lookme.lmtool.cracker.annotation.FilterAnnotation;
import com.lookme.lmtool.cracker.annotation.ParamAnnotation;
import com.lookme.lmtool.cracker.filter.AbstractFilter;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.awt.image.BufferedImageOp;

@FilterAnnotation(groupName = CrackerConstants.FILTER_GROUP_NAME_EFFECT,name="浮雕",filterClass = EmbossFilter.class)
public class FilterEmboss extends AbstractFilter {
    @XStreamAsAttribute
    @ParamAnnotation(name = "高度", desc = "凹凸高度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=100,blockIncrement = 5,majorTickUnit=10,minorTickCount = 2)
    private float bumpHeight=1.0f;
    @XStreamAsAttribute
    @ParamAnnotation(name = "角度", desc = "浮雕方位",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=360,blockIncrement = 5,majorTickUnit=90,minorTickCount = 3)
    private float azimuth=135.0f;
    @XStreamAsAttribute
    @ParamAnnotation(name = "光的高度", desc = "光的高度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=90,blockIncrement = 5,majorTickUnit=10,minorTickCount = 2)
    private float elevation=30f;

    @XStreamAsAttribute
    @ParamAnnotation(name = "显示主体", desc = "显示主体",inputType = ParamAnnotation.InputType.Radio,width = 45)
    boolean emboss=false;

    @Override
    public BufferedImageOp getFilter() {
        EmbossFilter filter= new EmbossFilter();
        filter.setBumpHeight(bumpHeight);
        filter.setAzimuth(azimuth * ImageMath.PI / 180.0f);
        filter.setElevation(elevation * ImageMath.PI / 180f);
        filter.setEmboss(emboss);
        return filter;
    }
}
